package com.xz.xzutils.settings.mybatislogplus;

import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.components.PersistentStateComponent;
import com.intellij.openapi.components.Service;
import com.intellij.openapi.components.State;
import com.intellij.openapi.components.Storage;
import org.jetbrains.annotations.NotNull;

/**
 * 持久化服务
 *
 * @author DONG.WANG17@HAND-CHINA.COM
 * @since 2025/3/3-03-03 01:06
 */

@Service
@State(name = "MybatisLogPlusPersistentState", storages = {@Storage("xz-utils.xml")})
public final class MybatisLogPlusPersistentState implements PersistentStateComponent<MybatisLogPlusState> {
    private MybatisLogPlusState mybatisLogPlusState = new MybatisLogPlusState();

    public static MybatisLogPlusPersistentState getInstance() {
        return ApplicationManager.getApplication().getService(MybatisLogPlusPersistentState.class);
    }

    @Override
    public @NotNull MybatisLogPlusState getState() {
        return mybatisLogPlusState;
    }

    @Override
    public void loadState(@NotNull MybatisLogPlusState mybatisLogPlusState) {
        this.mybatisLogPlusState = mybatisLogPlusState;
    }
}